cmake_minimum_required(VERSION 3.5)

project({{{packageName}}})

set(CMAKE_AUTOMOC ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network Gui)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network Gui)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

add_library(${PROJECT_NAME}
{{#models}}
{{#model}}
  {{classname}}.h
{{/model}}
{{/models}}
{{#apiInfo}}
{{#apis}}
{{#operations}}
  {{classname}}.h
{{/operations}}
{{/apis}}
{{/apiInfo}}
  {{prefix}}Helpers.h
  {{prefix}}HttpRequest.h
  {{prefix}}Object.h
  {{prefix}}Enum.h
  {{prefix}}HttpFileElement.h
  {{prefix}}ServerConfiguration.h
  {{prefix}}ServerVariable.h
  {{prefix}}Oauth.h
{{#models}}
{{#model}}
  {{classname}}.cpp
{{/model}}
{{/models}}
{{#apiInfo}}
{{#apis}}
{{#operations}}
  {{classname}}.cpp
{{/operations}}
{{/apis}}
{{/apiInfo}}
  {{prefix}}Helpers.cpp
  {{prefix}}HttpRequest.cpp
  {{prefix}}HttpFileElement.cpp
  {{prefix}}Oauth.cpp
  )

target_include_directories(${PROJECT_NAME}
    PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_link_libraries(${PROJECT_NAME}
    PUBLIC
        Qt${QT_VERSION_MAJOR}::Core
        Qt${QT_VERSION_MAJOR}::Network
        Qt${QT_VERSION_MAJOR}::Gui
    {{#contentCompression}}
    PRIVATE
        ${ZLIB_LIBRARIES}{{/contentCompression}}
)

configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
    "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
    INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)

install(
    TARGETS ${PROJECT_NAME}
    EXPORT ${PROJECT_NAME}Targets
    LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
    ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
    RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
    INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
)

install(
    FILES ${HEADER_FILES}
    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
)

install(
    FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
    DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

install(
    EXPORT ${PROJECT_NAME}Targets
    DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
